# 此为建表文件，如果没有在test的库上建表，就运行此文件。


import pymysql
# db_username 为数据库的相应帐号，db_password为数据库的访问密码， db_name为储存数据库的名称。
db = pymysql.connect("39.98.207.118","root","Zxzl123456","Gobang", charset='utf8') # 使用test库作为缓存信息载体
# db = pymysql.connect("localhost","debian-sys-maint","ctysTk7upM0cm2sV","Gobang", charset='utf8') # 使用test库作为缓存信息载体

cursor = db.cursor()
sql_1 = "CREATE TABLE user (username VARCHAR(200) NOT NULL,ip VARCHAR(50) NOT NULL," \
      "status INT NULL DEFAULT 0,PRIMARY KEY (ip))ENGINE = InnoDB character set utf8;"   # MYSQL命令语句 建表
cursor.execute(sql_1)
sql_2 = "CREATE TABLE main(game_num BIGINT NOT NULL AUTO_INCREMENT," \
        "locations MEDIUMTEXT NOT NULL ," \
        "win INT NOT NULL ," \
        "PRIMARY KEY (game_num))ENGINE = InnoDB"
cursor.execute(sql_2)
db.close()

